#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define XH(i,a,b) for(int i = a; i < b; ++i)
#define XXH(i,b,a) for(int i = b; i >= a; --i)
#define Module 998244353
int tmpInt;ll tmpll;string tmpStr;char tmpChar;
vector<int>tmpIntVector;

int main(){
  int n;cin>>n;
  int ans = -1;
  ll pNow = LLONG_MAX;
  XH(i,0,n){
    ll a,p,x;cin>>a>>p>>x;
    if(x - a > 0){
      if(p < pNow){
        ans = p;
        pNow = p;
      }
    } 
  }
  cout<<ans<<endl;

  return 0;
}
